package com.zhentao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhentao.pojo.Services;
import com.zhentao.vo.ServiceVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * 服务项目Mapper
 */
@Mapper
public interface ServicesMapper extends BaseMapper<Services> {
    
    /**
     * 获取服务详情（包含类别信息）
     */
    @Select("SELECT s.*, c.category_name, c.description as category_description, c.icon as category_icon " +
            "FROM services s " +
            "LEFT JOIN service_categories c ON s.category_id = c.id " +
            "WHERE s.id = #{id}")
    ServiceVO getServiceWithCategory(Long id);
    
    /**
     * 分页查询服务列表（包含类别信息）
     */
    @Select("SELECT s.*, c.category_name, c.description as category_description, c.icon as category_icon " +
            "FROM services s " +
            "LEFT JOIN service_categories c ON s.category_id = c.id " +
            "WHERE s.status = 1")
    IPage<ServiceVO> pageServiceWithCategory(Page<Services> page);
    
    /**
     * 获取指定类别下的所有服务
     */
    @Select("SELECT s.*, c.category_name, c.description as category_description, c.icon as category_icon " +
            "FROM services s " +
            "LEFT JOIN service_categories c ON s.category_id = c.id " +
            "WHERE s.category_id = #{categoryId} AND s.status = 1")
    List<ServiceVO> listServicesByCategoryId(Long categoryId);
}




